#!/usr/bin/python2.4
# Copyright 2009-2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================================================================

# Builds two versions of LongRunning. LongRunning.exe is a console app and will
# result in a console windows when run. LongRunningSilent.exe uses the Windows
# subsystem so that it does not throw up windows. It is useful for unit tests.
# There is a resource file, so that we can include a manifest that tells Windows
# Vista not to elevate this file. We need this when it is renamed to
# GoogleUpdate.exe for unit tests.

Import('env')

inputs = [
    'long_running.cc',
    env.RES('run_as_invoker.res', '$MAIN_DIR/common/run_as_invoker.rc'),
    ]

base_env = env.Clone()

base_env.Append(
    LIBS = [
        base_env['crt_libs'][base_env.Bit('debug')],
        ],
    CPPDEFINES = [
        'UNICODE',
        '_UNICODE'
        ],
)

if base_env.Bit('debug'):
  base_env.FilterOut(CCFLAGS=['/MTd'])
else:
  base_env.FilterOut(CCFLAGS=['/MT'])

# Duplicate the common settings then set the unique settings for each build.
silent_env = base_env.Clone()

# Use different subdirectory to avoid having 2 obj files with the same name.
silent_env['OBJPREFIX'] = 'silent/' + silent_env['OBJPREFIX']

silent_env.ComponentTestProgram(
    prog_name='LongRunningSilent',
    source=inputs,
    COMPONENT_TEST_RUNNABLE=False
)


base_env.FilterOut(LINKFLAGS = ['/SUBSYSTEM:WINDOWS'])
base_env['LINKFLAGS'] += [
    '/SUBSYSTEM:CONSOLE',
    '/ENTRY:WinMain',
    ]

base_env.ComponentTestProgram(
    prog_name='LongRunning',
    source=inputs,
    COMPONENT_TEST_RUNNABLE=False
)
